import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

export default defineConfig({
  plugins: [
    vue(),
    vueDevTools(),
  ],
  server: {
    host:"0.0.0.0",
    proxy: {
      '/product-service': {
        target: 'http://127.0.0.1:3000/api/v1',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/product-service/, ''),
      },
      '/user-service': {
        target: 'http://127.0.0.1:3001/api/v1',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/user-service/, ''),
      },
    }
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
